Socket
Socket
Sign inDemoInstall

@types/mime-types

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/mime-types

TypeScript definitions for mime-types


Version published
Weekly downloads
2.7M
decreased by-0.15%
Maintainers
1
Weekly downloads
 
Created

What is @types/mime-types?

@types/mime-types is a TypeScript type definition package for the mime-types library. The mime-types library is used to work with MIME types, which are used to specify the nature and format of a document, file, or assortment of bytes. This package provides type definitions to ensure type safety and better development experience when using the mime-types library in TypeScript projects.

What are @types/mime-types's main functionalities?

Lookup MIME Type

This feature allows you to look up the MIME type based on a file extension. In this example, the MIME type for a .txt file is retrieved.

const mime = require('mime-types');
const mimeType = mime.lookup('example.txt');
console.log(mimeType); // 'text/plain'

Lookup File Extension

This feature allows you to look up the file extension based on a MIME type. In this example, the file extension for 'text/plain' is retrieved.

const mime = require('mime-types');
const extension = mime.extension('text/plain');
console.log(extension); // 'txt'

Add Custom MIME Type

This feature allows you to define custom MIME types. In this example, a custom MIME type 'application/x-my-type' is defined for the file extension 'mytype'.

const mime = require('mime-types');
mime.define({'application/x-my-type': ['mytype']});
const mimeType = mime.lookup('file.mytype');
console.log(mimeType); // 'application/x-my-type'

Other packages similar to @types/mime-types

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc